package com.emergency.direct.controller;

import com.emergency.direct.service.ScenarService;
import com.emergency.base.domain.Scenar;
import com.emergency.common.entity.Result;
import com.emergency.common.entity.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Created by lijie on 2019/10/21.
 */
@RestController
@RequestMapping("/scenar")
@Api(value="想定类",description = "想定编辑类，包括想定基本信息模块、环境信息")
public class ScenarController {

    @Autowired
    private ScenarService scenarService;

    @ApiOperation(value = "想定增加或修改接口" ,notes="想定增加修改")
    @RequestMapping(value = "info/add",method = RequestMethod.POST)
    public Result add(@RequestBody Scenar scenar){
        String id=scenarService.add(scenar);
        return new Result(true, StatusCode.OK,  "操作成功", id);
    }

    @ApiOperation(value = "想定增加或修改接口" ,notes="预留接口接入第三方")
    @RequestMapping(value = "/third/info/add",method = RequestMethod.POST)
    public Result add(String scenar){

        return new Result(true, StatusCode.OK,  "操作成功", "");
    }

    @ApiOperation(value = "想定信息获取接口" ,  notes="想定信息获取")
    @RequestMapping(value = "info/get",method = RequestMethod.GET)
    public Result get(Long scenarId){
        Scenar scenar=scenarService.get(scenarId);
        return new Result(true, StatusCode.OK,  "操作成功", scenar);
    }


    @ApiOperation(value = "想定列表获取接口" ,notes="想定列表")
    @RequestMapping(value = "list/{page}/{size}",method = RequestMethod.POST)
    public Result list(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){
        Page<Scenar> pageList = scenarService.findList(searchMap, page, size);
        return new Result(true, StatusCode.OK,  "操作成功", pageList);
    }
}
